<template>
	<a-spin :spinning="loading">
		<a-card>
			<section slot="title">商家列表</section>
			<a-row :gutter="16">
				<a-col :span="5">
					<span class="label">企业名称：</span>
					<a-input :max-length="100" allow-clear v-model="search_data.companyName" placeholder="请输入" />
				</a-col>	
        <a-col :span="5">
					<span class="label">法人名称：</span>
					<a-input :max-length="100" allow-clear v-model="search_data.legalName" placeholder="请输入" />
				</a-col>
				<a-col :span="5">
					<span class="label">企业类型：</span>
					<a-select v-model="search_data.companyType" class="w-full" allow-clear placeholder="请选择">
						<a-select-option :value="1">个人</a-select-option>
						<a-select-option :value="2">企业</a-select-option>
					</a-select>
				</a-col>
			<!-- 	<a-col :span="5">
					<span class="label">状态：</span>
					<a-select v-model="status" class="w-full" allow-clear placeholder="请选择">
						<a-select-option :value="1">测试数据</a-select-option>
					</a-select>
				</a-col> -->
				<a-col :span="5">
					<span class="label">手机号：</span>
					<a-input :max-length="100" allow-clear v-model="search_data.mobile" placeholder="请输入" />
				</a-col>


				<a-col :span="8">
					<a-button class="ml-18" type="primary" @click="search">查询</a-button>
					<a-button class="mx-8" @click="reset">重置</a-button>
					<a-button @click="getEdit" class="mx-8" type="primary">新增</a-button>
					<a-button type="primary" ghost class="ml-10 border-5" @click="exportTable">导出</a-button>
				</a-col>
			</a-row>
			<a-table class="mt-16 order-table" :columns="columns" :data-source="data" :scroll="scroll"
				:pagination="pagination">
				<!-- 企业类型 -->
				<template #companyType="companyType, data">
					{{ data.companyType == 1 ? '个人' : '企业' }}
				</template>

				<!-- 审核状态 -->
				<template #approveStatus="approveStatus, data">
					<span v-if="approveStatus==0">待审核</span>
					<span v-if="approveStatus==1">审核通过</span>
					<span v-if="approveStatus==2">审核不通过</span>
				</template>
				<template #action="action, data">
					<a-button @click="goCharts(data)" style="background:#32CD32;" type="primary">
						编辑
					</a-button>
				</template>
			</a-table>
			<!-- <a-divider  /> -->
		</a-card>
		<create @upload="upload" ref="create"></create>
	</a-spin>
</template>
<script>
	import create from './components/create.vue'
	import {
		getBusiness
	} from '@/api/newPet'
	import {
		tableMixins
	} from '@/utils/mixins'
	export default {
		mixins: [tableMixins],
		components: {
			create
		},
		data() {
			return {
				loading: false,
				tabs: 'select1',
				orderId: undefined,
				ceartTime: [undefined, undefined],
				status: null,
				search_data: {

				},
				data: [],
				columns: [{
						title: '序号',
						dataIndex: 'id',
						align: 'center',
						width: 50,
						scopedSlots: {
							customRender: 'id'
						}
					},
					{
						title: '企业名称',
						dataIndex: 'companyName',
						align: 'center',
						width: 140,
						scopedSlots: {
							customRender: 'companyName'
						}
					},
					{
						title: '企业类型',
						dataIndex: 'companyType',
						width: 100,
						align: 'center',
						scopedSlots: {
							customRender: 'companyType'
						}
					},
					{
						title: '统一社会信用代码',
						dataIndex: 'generalCreditCode',
						align: 'center',
						width: 140,
						scopedSlots: {
							customRender: 'generalCreditCode'
						}
					},
					{
						title: '法人姓名',
						dataIndex: 'legalName',
						align: 'center',
						width: 140,
						scopedSlots: {
							customRender: 'legalName'
						}
					},

					{
						title: '法人身份证号',
						dataIndex: 'legalIdCard',
						align: 'center',
						width: 200,
						scopedSlots: {
							customRender: 'legalIdCard'
						}
					},
					{
						title: '注册人昵称',
						dataIndex: 'nickName',
						align: 'center',
						width: 140,
						scopedSlots: {
							customRender: 'nickName'
						}
					},
					{
						title: '注册人手机号',
						dataIndex: 'mobile',
						align: 'center',
						width: 200,
						scopedSlots: {
							customRender: 'mobile'
						}
					},
					{
						title: '状态',
						dataIndex: 'approveStatus',
						align: 'center',
						width: 70,
						scopedSlots: {
							customRender: 'approveStatus'
						}
					},


					{
						title: '操作',
						fixed: 'right',
						dataIndex: 'action',
						width: 160,
						scopedSlots: {
							customRender: 'action'
						},
						align: 'center'
					}
				]
			}
		},
		computed: {},
		watch: {},
		async created() {
			this.getData()
		},
		methods: {
			search() {
				this.pageNum = 1
				this.getData()
			},
			upload() {
				this.search()
			},
			delect(data) {
				this.$confirm({
					title: '删除',
					content: `请确认是否取消该商品？`,
					okText: '确定',
					okType: 'danger',
					cancelText: '取消',
					onOk: () => {
						console.log('删除')
						return
						this.loading = true
						deductionDetail({
								deductId: data.id
							})
							.then(res => {
								this.$message.success('删除成功！')

								this.search()

								this.loading = false
							})
							.finally(() => (this.loading = false))
					}
				})
			},
			goCharts(data) {
				this.$refs.create.open(data)
			},
			getEdit(data) {
				this.$refs.create.open(data)
			},
			getSearchParams() {
				console.log(this.vendorId)
				return {
					pageNo: this.pageNum,
					pageSize: this.rowsNum,
					startTime: this.$utils.getStartTime(this.ceartTime[0]),
					endTime: this.$utils.getEndTime(this.ceartTime[1]),
					...this.search_data
					// approveStatus:1
				}
			},
			getData() {
				this.loading = true
				getBusiness(this.getSearchParams())
					.then(data => {
						this.total = data.total;
						this.data = data.list;
					})
					.finally(() => (this.loading = false))
			},
			reset() {
				this.ceartTime = [undefined, undefined]
        this.search_data = {}
			}
		}
	}
</script>
<style lang="less" scoped>
	.ant-col {
		margin-bottom: 20px;
		display: flex;
		align-items: center;

		.label {
			flex-shrink: 0;
			width: 100px;
			text-align: right;
			font-size: 14px;
			color: #595959;
		}

		.w-full {
			flex: 1;
		}
	}
</style>